package com.cms.action;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import com.action.DefaultAction;
import com.cms.manager.ChannelPercentManager;
import com.cms.model.AppInfo;
import com.cms.model.AppVersionInfo;
import com.cms.model.Channel;
import com.cms.model.ChannelPercent;
import com.cms.model.ImportChannelData;
import com.cms.model.ImportData;
import com.cms.model.ImportLog;
import com.cms.model.TerraceInfo;
import com.cms.service.AppInfoService;
import com.cms.service.AppInfoServiceImpl;
import com.cms.service.AppVersionInfoServiceImpl;
import com.cms.service.ChannelService;
import com.cms.service.ChannelServiceImpl;
import com.cms.service.ImportDataService;
import com.cms.service.ImportDataServiceImpl;
import com.cms.service.ImportLogService;
import com.cms.service.ImportLogServiceImpl;
import com.cms.service.TerraceInfoServiceImpl;
import com.cms.sync.model.KpaySyncLog;
import com.util.Config;
import com.util.ConfigUtil;
import com.util.FileDigest;
import com.util.Util;

public class ImportDataAction extends DefaultAction {
private static final long serialVersionUID = 1L;
	
	public ImportDataAction()
	{
	}
	private File Filedata;
	private String FiledataFileName;
	private String FiledataContentType;
	private ImportLog logmodel;
	
	private String startday;
	private String endday;
	private String type;
	
	List<ImportData> datalist = new ArrayList<ImportData>();
	List<KpaySyncLog> datalist1 = new ArrayList<KpaySyncLog>();
	AppInfoService appservice = new AppInfoServiceImpl();
	List<AppInfo> applist ;
	List<AppVersionInfo> appversionlist;
	List<Channel> channellist;
	ChannelService channelservice = new ChannelServiceImpl();
	ImportLogService ilservice = new ImportLogServiceImpl();
	ImportDataService service = new ImportDataServiceImpl();
	public String show()
	{
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DATE, -1);
		startday=endday=Util.dateToString(c.getTime(), "yyyyMMdd");
		return SUCCESS;
	}
	public boolean isEmpty(HSSFCell cell){
		return cell!=null&&!"".equals(cell);
	}
	public String newView(){
		try {
			POIFSFileSystem fs =new POIFSFileSystem(new FileInputStream(logmodel.getFilesrc()));
			
		    HSSFWorkbook wb = new HSSFWorkbook(fs);
	
		    HSSFSheet sheet = wb.getSheetAt(0);
		    
		    int firstRowNum = sheet.getFirstRowNum();
		    int lastRowNum=sheet.getLastRowNum();
		    if(firstRowNum>=lastRowNum)
		    {
		    	addActionError("数据文件解析错误，请检查重传！");
				return INPUT;
		    }
		    HSSFRow row = null;
		    
		    ImportData data = null;
		    for(int i =firstRowNum+1;i<=lastRowNum;i++)
		    {
		    	data = new ImportData();
		    	row = sheet.getRow(i);
		    	if(row!=null)
		    	{
		    		HSSFCell cell = row.getCell(0);
		    		String day="";
		    		if(isEmpty(cell))
		    			day = cell.toString().trim();
		    		
		    		cell = row.getCell(1);
		    		String appnumber = "";
		    		if(isEmpty(cell))
		    			appnumber = cell.toString().trim();
		    		
		    		cell = row.getCell(3);
		    		String appversionnumber = "";
		    		if(isEmpty(cell))
		    			appversionnumber = cell.toString().trim();
		    		
		    		cell = row.getCell(5);
		    		String channelid = "";
		    		if(isEmpty(cell))
		    			channelid = cell.toString().trim();
		    		
		    		cell = row.getCell(7);
		    		String operator = "";
		    		if(isEmpty(cell))
		    			operator = cell.toString().trim();
		    		
		    		cell = row.getCell(8);
		    		String source = "";
		    		if(isEmpty(cell))
		    			source = cell.toString().trim();
		    		
		    		cell = row.getCell(10);
		    		String fee = "";
		    		if(isEmpty(cell))
		    			fee = cell.toString().trim();
		    		
		    		String newusers="0";
		    		cell = row.getCell(11);
		    		if(isEmpty(cell))
		    		{
		    			newusers = cell.toString().trim();
		    			if(newusers.indexOf(".0")>-1)
		    			{
		    				newusers = newusers.replace(".0","");
		    			}
		    		}
		    		
		    		String activeuser="0";
		    		cell = row.getCell(12);
		    		if(isEmpty(cell))
		    		{
		    			activeuser = cell.toString().trim();
		    			if(activeuser.indexOf(".0")>-1)
		    			{
		    				activeuser = activeuser.replace(".0","");
		    			}
		    		}
		    		
		    		String payingcustomers="0";
		    		cell = row.getCell(13);
		    		if(isEmpty(cell))
		    		{
		    			payingcustomers = cell.toString().trim();
		    			if(payingcustomers.indexOf(".0")>-1)
		    			{
		    				payingcustomers = payingcustomers.replace(".0","");
		    			}
		    		}
		    		
		    		String paidnumber="0";
		    		cell = row.getCell(14);
		    		if(isEmpty(cell))
		    		{
		    			paidnumber = cell.toString().trim();
		    			if(paidnumber.indexOf(".0")>-1)
		    			{
		    				paidnumber = paidnumber.replace(".0","");
		    			}
		    		}
		    		
		    		if(!"".equals(day) && !"".equals(fee))
		    		{
		    			data.setDay(Integer.parseInt(day.replaceAll("-", "")));
		    			data.setAppnumber(appnumber);
		    			data.setAppversionnumber(appversionnumber);
		    			data.setChannelid(Integer.parseInt(channelid.replaceAll("\\.0", "")));
		    			//data.setGoodsname(goodsname);
		    			data.setOperator(operator);
		    			data.setSource(source);
		    			//data.setProvince(province);
		    			data.setFee(Float.parseFloat(fee));
		    			data.setNewusers(Integer.parseInt(newusers.trim()));
		    			data.setActiveuser(Integer.parseInt(activeuser.trim()));
		    			data.setPayingcustomers(Integer.parseInt(payingcustomers.trim()));
		    			data.setPaidnumber(Integer.parseInt(paidnumber.trim()));
		    			datalist.add(data);
		    		}
		    	}
		    }
		} catch (Exception ex) {
			addActionError("数据文件解析错误，请检查重传！errmsg:"+ex.getMessage());
			System.out.println("导入数据，不知道哪出问题？"+ex.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}
	public String view()
	{
		applist = appservice.getAppInfos();
		appversionlist = new AppVersionInfoServiceImpl().getAppVersionInfos();
		channellist = channelservice.getChannels();
		if("newview".equals(type)){
			return newView();
		}
		try{
			POIFSFileSystem fs =new POIFSFileSystem(new FileInputStream(logmodel.getFilesrc()));
	
		    HSSFWorkbook wb = new HSSFWorkbook(fs);
	
		    HSSFSheet sheet = wb.getSheetAt(0);
		    
		    int firstRowNum = sheet.getFirstRowNum();
		    int lastRowNum=sheet.getLastRowNum();
		    if(firstRowNum>=lastRowNum)
		    {
		    	addActionError("数据文件解析错误，请检查重传！");
				return INPUT;
		    }
		    HSSFRow row = null;
		    
		    ImportData data = null;
		    for(int i =firstRowNum+1;i<=lastRowNum;i++)
		    {
		    	data = new ImportData();
		    	row = sheet.getRow(i);
		    	if(row!=null)
		    	{
		    		HSSFCell cell = row.getCell((short)0);
		    		String day = "";
		    		if(cell!=null)
		    			day = cell.toString().trim();
		    		
		    		cell = row.getCell((short)1);
		    		String appid = "";
		    		if(cell!=null)
		    			appid = cell.toString().trim();
		    		
		    		cell = row.getCell((short)2);
		    		String appname = "";
		    		if(cell!=null)
		    			appname = cell.toString().trim();
		    		
		    		cell = row.getCell((short)3);
		    		String appversionname = "";
		    		if(cell!=null)
		    			appversionname = cell.toString().trim();
		    		
		    		cell = row.getCell((short)4);
		    		String channelname = "";
		    		if(cell!=null)
		    			channelname = cell.toString().trim();
		    		
		    		cell = row.getCell((short)5);
		    		String goodsname = "";
		    		if(cell!=null)
		    			goodsname = cell.toString().trim();
		    		
		    		cell = row.getCell((short)6);
		    		String op = "";
		    		if(cell!=null)
		    			op = cell.toString().trim();
		    		
		    		cell = row.getCell((short)7);
		    		String source = "";
		    		if(cell!=null)
		    			source = cell.toString().trim();
		    		
		    		cell = row.getCell((short)8);
		    		String province = "";
		    		if(cell!=null)
		    			province = cell.toString().trim();
		    		
		    		cell = row.getCell((short)9);
		    		String fee = "";
		    		if(cell!=null)
		    			fee = cell.toString().trim();
		    		
		    		String newusers="0";
		    		cell = row.getCell((short)10);
		    		if(cell!=null && !"".equals(cell.toString().trim()))
		    		{
		    			newusers = cell.toString().trim();
		    			if(newusers.indexOf(".0")>-1)
		    			{
		    				newusers = newusers.replace(".0","");
		    			}
		    		}
		    		
		    		String activeuser="0";
		    		cell = row.getCell((short)11);
		    		if(cell!=null && !"".equals(cell.toString().trim()))
		    		{
		    			activeuser = cell.toString().trim();
		    			if(activeuser.indexOf(".0")>-1)
		    			{
		    				activeuser = activeuser.replace(".0","");
		    			}
		    		}
		    		
		    		String payingcustomers="0";
		    		cell = row.getCell((short)12);
		    		if(cell!=null && !"".equals(cell.toString().trim()))
		    		{
		    			payingcustomers = cell.toString().trim();
		    			if(payingcustomers.indexOf(".0")>-1)
		    			{
		    				payingcustomers = payingcustomers.replace(".0","");
		    			}
		    		}
		    		
		    		String paidnumber="0";
		    		cell = row.getCell((short)13);
		    		if(cell!=null && !"".equals(cell.toString().trim()))
		    		{
		    			paidnumber = cell.toString().trim();
		    			if(paidnumber.indexOf(".0")>-1)
		    			{
		    				paidnumber = paidnumber.replace(".0","");
		    			}
		    		}
		    		
		    		if(!"".equals(day) && !"".equals(fee))
		    		{
		    			if(fee.endsWith(".0"))
		    			{
		    				fee = fee.substring(0,(fee.length()-2));
		    			}
		    			String appnumber = "";
		    			if(!"".equals(appid.trim()))
		    			{
			    			for(int j=0;j<applist.size();j++)
			    			{
			    				if(applist.get(j).getAppnumber().equals(appid))
			    				{
			    					appnumber = applist.get(j).getAppnumber();
			    					break;
			    				}
			    					
			    			}
		    			}
		    			else
		    			{
		    				for(int j=0;j<applist.size();j++)
			    			{
			    				if(applist.get(j).getAppname().equals(appname))
			    				{
			    					appnumber = applist.get(j).getAppnumber();
			    					break;
			    				}
			    					
			    			}
		    				if(appnumber==null || appnumber.equals(""))
		    				{
			    				for(int j=0;j<applist.size();j++)
				    			{
				    				if(applist.get(j).getAppname().indexOf(appname)>-1)
				    				{
				    					appnumber = applist.get(j).getAppnumber();
				    					break;
				    				}
				    					
				    			}
		    				}
		    			}
		    			//appversionnumber
		    			String appversionnumber="";
		    			for(int j=0;j<appversionlist.size();j++)
		    			{
		    				AppVersionInfo avi = appversionlist.get(j);
		    				if(avi.getAppname().equals(appversionname))
		    				{
		    					appversionnumber = avi.getAppversionnumber();
		    					break;
		    				}
		    					
		    			}
	    				if(appversionnumber==null || appversionnumber.equals(""))
	    				{
		    				for(int j=0;j<appversionlist.size();j++)
			    			{
		    					AppVersionInfo avi = appversionlist.get(j);
			    				if(avi.getAppname().indexOf(appversionname)>-1)
			    				{
			    					appversionnumber = avi.getAppversionnumber();
			    					break;
			    				}
			    					
			    			}
	    				}
		    			data.setDay(Integer.parseInt(day.replace("-","").trim()));
		    			data.setAppnumber(appnumber);
		    			data.setAppversionnumber(appversionnumber);
		    			int channelid = -1;
		    			if(!"".equals(channelname))
		    			{
		    				for(int j = 0;j<channellist.size();j++)
			    			{
			    				if(channellist.get(j).getName().equals(channelname))
			    				{
			    					channelid = channellist.get(j).getId();
			    					break;
			    				}
			    			}
		    				if(channelid==-1)
		    				{
				    			for(int j = 0;j<channellist.size();j++)
				    			{
				    				if(channellist.get(j).getName().indexOf(channelname)>-1)
				    				{
				    					channelid = channellist.get(j).getId();
				    					break;
				    				}
				    			}
		    				}
		    			}
		    			data.setChannelid(channelid);
		    			data.setGoodsname(goodsname);
		    			data.setOperator(op);
		    			data.setSource(source);
		    			data.setProvince(province);
		    			data.setFee(Float.parseFloat(fee));
		    			data.setNewusers(Integer.parseInt(newusers.trim()));
		    			data.setActiveuser(Integer.parseInt(activeuser.trim()));
		    			data.setPayingcustomers(Integer.parseInt(payingcustomers.trim()));
		    			data.setPaidnumber(Integer.parseInt(paidnumber.trim()));
		    			datalist.add(data);
		    		}
		    	}
		    }
	
		}catch(Exception ex)
		{
			addActionError("数据文件解析错误，请检查重传！errmsg:"+ex.getMessage());
			System.out.println("导入数据，不知道哪出问题？"+ex.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}
	public String formatfee(String fee)
	{
		if(fee.endsWith(".0"))
		{
			fee = fee.substring(0,(fee.length()-2));
		}
		return fee;
	}
	int datanumber;
	String msg;
	public String save()
	{
		logmodel.setCreateuser(getAdminLoginName());
		logmodel.setCreatedate(Util.dateToString(new Date()));
		try{
			if(ilservice.insertImportLog(logmodel))
			{
				ImportData data;
				Map<String,AppInfo> cache = new HashMap<String,AppInfo>();
				for(int i=1;i<=datanumber;i++)
				{
					data = new ImportData();
					data.setDatafileid(logmodel.getId());
					data.setDay(Integer.parseInt(getParameter("day"+i)));
					data.setAppnumber(getParameter("appnumber"+i));
					data.setAppversionnumber(getParameter("appversionnumber"+i));
					String appNumber = data.getAppnumber();
					if(!cache.containsKey(appNumber)){						
						cache.put(appNumber, appservice.getAppInfoByAppNumber(appNumber));
					}
					data.setCpid(cache.get(appNumber).getCpid());
					data.setChannelid(Integer.parseInt(getParameter("channelid"+i)));
					data.setGoodsname(getParameter("goodsname"+i));
					data.setOperator(getParameter("operator"+i));
					data.setSource(getParameter("source"+i));
					data.setProvince(getParameter("province"+i));
					data.setFee(Float.parseFloat(getParameter("fee"+i)));
					
					data.setNewusers(Integer.parseInt(getParameter("newusers"+i)));
	    			data.setActiveuser(Integer.parseInt(getParameter("activeuser"+i)));
	    			data.setPayingcustomers(Integer.parseInt(getParameter("payingcustomers"+i)));
	    			data.setPaidnumber(Integer.parseInt(getParameter("paidnumber"+i)));
					datalist.add(data);
				}
				if(!service.saveImportData(datalist))
				{
					
					msg = "数据导入：数据导入失败！";
				}
				else{
					msg = "数据导入：数据导入成功！";
					//List<ImportCpData> cpdatalist = new ArrayList<ImportCpData>();
					List<ImportChannelData> channeldatalist = new ArrayList<ImportChannelData>();
					//ImportCpData cpdata;
					ImportChannelData channeldata;
					//扣量比例
					Map<String,ChannelPercent> chpmap = ChannelPercentManager.getInstance().getChpByChannelAndAversion();
					for(int i =0;i<datalist.size();i++)
					{
						//cpdata = new ImportCpData(datalist.get(i));
						//cpdatalist.add(cpdata);
						channeldata = new ImportChannelData(checkChannelPercent(datalist.get(i),chpmap));
						channeldatalist.add(channeldata);
					}
					//service.saveImportCpData(cpdatalist);
					service.saveImportChannelData(channeldatalist);
				}
			}else
			{
				msg = "数据导入：数据导入失败！数据导入历史记录添加失败。";
			}
		}catch(Exception ex)
		{
			msg = "数据导入：数据导入失败！errmsg:"+ex.getMessage();
		}
		return SUCCESS;
	}
	private ImportData checkChannelPercent(ImportData item,Map<String,ChannelPercent> chpmap){
		if(chpmap==null||chpmap.size()<=0){
			return item;
		}
		String key = item.getChannelid()+"_"+item.getAppversionnumber();
		if(!chpmap.containsKey(key))
			return item;
		ChannelPercent chp = chpmap.get(key);
		int percent = chp.getDaypercent();
		item.setNewusers(item.getNewusers()*percent/100);
		item.setActiveuser(item.getActiveuser()*percent/100);
		item.setPaidnumber(item.getPaidnumber()*percent/100);
		item.setPayingcustomers(item.getPayingcustomers()*percent/100);
		String feestr = String.valueOf(item.getFee());
		if(feestr.indexOf(".")!=-1){
			String[] arr = feestr.split("\\."); //去尾 整数部分乘以比例
			String tmpfee = String.valueOf(Integer.parseInt(arr[0])*percent/100);
			feestr = tmpfee+"."+arr[1];
		}
		item.setFee(Float.valueOf(feestr));
		return item;
	}
	public String uploaddatafile()
	{
		if(Filedata!=null)
		{
			String reiconname = FileDigest.getFileMD5(Filedata);
			String filesrc = ConfigUtil.get(Config.SECTIONMANAGE, Config.KEY_IMPORTDATA_SAVE_PATH) + 
			"/"+reiconname;
			saveUploadFile(Filedata,filesrc);
			logmodel = new ImportLog();
			logmodel.setFilename(FiledataFileName);
			logmodel.setRefilename(reiconname);
			logmodel.setFilesrc(filesrc);
		}
		return SUCCESS;
	}
	
	public String index(){
		if(type!=null&&type.equals("query")){
			datalist1 = service.getSyncDataAsImportData(startday, endday);
			if(datalist1.size()>0){
				List<AppInfo> applist = appservice.getAppInfos(); // app list
				List<AppVersionInfo> appvlist = new AppVersionInfoServiceImpl().getAppVersionInfos(); // appv list
				List<Channel> chlist = channelservice.getChannels(); // channel list
				List<TerraceInfo> terracelist = new TerraceInfoServiceImpl().getTerraceInfos();
				
				Map<String,Object> cacheMap = new HashMap<String,Object>();
				for (Channel channel : chlist) {
					cacheMap.put("channel_"+channel.getId(), channel);
				}
				for (AppVersionInfo appv : appvlist) {
					cacheMap.put("appv_"+appv.getAppversionnumber(), appv);
				}
				for (AppInfo app : applist) {
					cacheMap.put("app_"+app.getAppnumber(), app);
				}
				for (TerraceInfo terrace : terracelist) {
					cacheMap.put("terrace_"+terrace.getCode(), terrace);
				}
				
				KpaySyncLog data = null;
				
				final int num = 15; //总共15列
				// 创建Excel文档  
		        HSSFWorkbook hwb = new HSSFWorkbook(); 
		        // sheet 对应一个工作页  
		        HSSFSheet sheet = hwb.createSheet("importdata");  
		        HSSFRow firstrow = sheet.createRow(0); // 下标为0的行开始  
		        HSSFCell[] firstcell = new HSSFCell[num];  
		        String[] names = new String[num];  
		        names[0]="日期";names[1]="AppNumber";names[2]="游戏名称";names[3]="AppversionNumber";names[4]="游戏版本名称";
		        names[5]="channelId";names[6]="渠道名称";names[7]="运营商";names[8]="收入来源";names[9]="采集收入（元）";names[10]="收入（元）";names[11]="新增用户数";names[12]="活跃用户数";
		        names[13]="付费用户数";names[14]="付费次数";
		        for (int j = 0; j < num; j++) {  
		            firstcell[j] = firstrow.createCell(j);  
		            firstcell[j].setCellValue(new HSSFRichTextString(names[j])); 
		        } 
		        for (int i = 0; i < datalist1.size(); i++) {  
		            // 创建一行  
		            HSSFRow row = sheet.createRow(i + 1);  
		            // 得到要插入的每一条记录  
		            data = datalist1.get(i);  
		            String appnumber="";
		            String appname  = "未知";
		            String appvname = "未知";
		            String chname   = "未知";
		            String source   = "未知";
		            if(cacheMap.containsKey("appv_"+data.getAppversionnumber())){
						AppVersionInfo appv = (AppVersionInfo)cacheMap.get("appv_"+data.getAppversionnumber());
						appvname=appv.getAppname();
						if(cacheMap.containsKey("app_"+appv.getAppnumber())){
							AppInfo app = (AppInfo)cacheMap.get("app_"+appv.getAppnumber());
							appnumber=app.getAppnumber();
							appname=app.getAppname();
						}
					}
		            if(data.getChannelid()!=-1&&cacheMap.containsKey("channel_"+data.getChannelid())){
		            	Channel ch = (Channel)cacheMap.get("channel_"+data.getChannelid());
		            	chname = ch.getName();
		            }
		            if(cacheMap.containsKey("terrace_"+data.getProvider())){
		            	TerraceInfo terrace = (TerraceInfo)cacheMap.get("terrace_"+data.getProvider());
		            	source = terrace.getOperatorsName();
		            }
		            
		            for (int colu = 0; colu < 10; colu++) {  
		                // 在一行内循环  
		                HSSFCell xh = row.createCell(colu); 
		                switch (colu) {
						case 0:
							xh.setCellValue(Util.dateToString(Util.stringToDate(String.valueOf(data.getDay()), "yyyyMMdd"), "yyyy-MM-dd"));
							break;
						case 1:
							xh.setCellValue(appnumber);
							break;
						case 2:
							xh.setCellValue(appname);
							break;
						case 3:
							xh.setCellValue(data.getAppversionnumber());
							break;
						case 4:
							xh.setCellValue(appvname);
							break;
						case 5:
							xh.setCellValue(data.getChannelid());
							break;
						case 6:
							xh.setCellValue(chname+"("+data.getChid()+")");
							break;
						case 7:
							xh.setCellValue(data.getOperatorname());	
							break;
						case 8:
							xh.setCellValue(source);
							break;
						case 9:
							xh.setCellValue(data.getOrderamount()/100);
							break;
						default:
							break;
						}
		            }  
		        } 
		        
		        try {
		        	String reiconname="datatemplate.xls";
			        String filesrc = ConfigUtil.get(Config.SECTIONMANAGE, Config.KEY_IMPORTDATA_SAVE_PATH) + 
			    			"/"+reiconname;
			        // 创建文件输出流，准备输出电子表格  
			        OutputStream out = new FileOutputStream(filesrc);  
			        hwb.write(out);  
			        out.close();  
			        
			        HttpServletResponse response = super.getResponse();
					InputStream is = new BufferedInputStream(new FileInputStream(filesrc));
					byte[] b = new byte[is.available()];
					is.read(b);
					is.close();
					
					String fileName = reiconname;
					
			    	response.setContentType("application/octet-stream");
			    	response.setHeader("Location", fileName);
			    	response.setHeader("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes("gb2312"), "ISO8859-1"));
			    	OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
			    	outputStream.write(b);
			    	outputStream.flush();
			    	outputStream.close();
				} catch (Exception e) {
					// TODO: handle exception
					e.printStackTrace();
				}
		        return null;
			}
		}
		return SUCCESS;
	}
	
	public File getFiledata() {
		return Filedata;
	}
	public void setFiledata(File filedata) {
		Filedata = filedata;
	}
	public String getFiledataFileName() {
		return FiledataFileName;
	}
	public void setFiledataFileName(String filedataFileName) {
		FiledataFileName = filedataFileName;
	}
	public String getFiledataContentType() {
		return FiledataContentType;
	}
	public void setFiledataContentType(String filedataContentType) {
		FiledataContentType = filedataContentType;
	}
	public ImportLog getLogmodel() {
		return logmodel;
	}
	public void setLogmodel(ImportLog logmodel) {
		this.logmodel = logmodel;
	}
	public List<ImportData> getDatalist() {
		return datalist;
	}
	public void setDatalist(List<ImportData> datalist) {
		this.datalist = datalist;
	}
	public List<AppInfo> getApplist() {
		return applist;
	}
	public void setApplist(List<AppInfo> applist) {
		this.applist = applist;
	}
	public List<Channel> getChannellist() {
		return channellist;
	}
	public void setChannellist(List<Channel> channellist) {
		this.channellist = channellist;
	}
	public int getDatanumber() {
		return datanumber;
	}
	public void setDatanumber(int datanumber) {
		this.datanumber = datanumber;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public List<AppVersionInfo> getAppversionlist() {
		return appversionlist;
	}
	public void setAppversionlist(List<AppVersionInfo> appversionlist) {
		this.appversionlist = appversionlist;
	}
	public String getStartday() {
		return startday;
	}
	public void setStartday(String startday) {
		this.startday = startday;
	}
	public String getEndday() {
		return endday;
	}
	public void setEndday(String endday) {
		this.endday = endday;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
}
